/*Author:S.Genikhov
Creatin Date:
Last modified:11/Sept/2010
Reviewed by :

Version 3 with possiblitiest to : Login,get,Bye and simple Security check.
Support only TCP connection.

Short project description:
Bases reallisation of FTP server command like : cd ,send recieve file and commands,
by using of state machine*/

#ifndef FTPPROTOCOL_H_INCLUDED
#define FTPPROTOCOL_H_INCLUDED

#define         COMMANDLENGTH         (10) /*Used as lengh of single command
                                             of events and also max length of ether name or password*/
#define         MAXPROMTLENGH         (100)/*Maximal lenght of command promt* command + param or PATH*/
#define         MAXPACKETSIZE         (1500)/*Maximal size of packet wich coud be transfered*/
#define         UDP_PORT              (19734)/*Define the connection port of FTPclient to FTP server*/

extern  char  FTPevents[][COMMANDLENGTH];
extern  char  FTPresponds[][MAXPROMTLENGH];/*Maximal lenght of command promt* command + param or PATH*/

enum FTPevent_enum   { FTP_ERR_E      = 0,FTP_User_E     = 1,FTP_PASS_E     = 2,
                       FTP_Bye_E      = 3,FTP_get_E      = 4,FTP_cd_E       = 5,
                       FTP_ls_E       = 6,FTP_COMMAND_E  = 6,FTP_NUMEVENT_E = 7
};


typedef enum FTPresponds {   FTP_INS_PASS   = 0, FTP_SUCC_WELCOME = 1, FTP_FAIL_INS_USR     = 2,
                             FTP_FAIL_3TIME = 3, FTP_ILIGAL_COMND = 4, FTP_SRV_ERROR        = 5,
                             FTP_WR_COM_USR = 6, FTP_NO_FILE      = 7, FTP_FILE_TRANS_ERR   = 8,
                             FTP_USR_BLOCK  = 9, FTP_STOP_COMMAND = 10,FTP_FOLDER_NOT_EXIST = 11,
                             FTP_STRING     =255
}FTPresp_E;


typedef unsigned int uint;
typedef struct FTPHeader_t
{
    union bitfildint
    {
        struct Uheader
        {
            uint     m_datasize    :12;
            uint     m_errnum      :8;
            uint     m_islast      :1;
            uint     m_reserved    :9;
            uint     m_iscommand   :2;

        }FTPUnionHeader;

        uint         m_headerAsUnit;
    } u_FTPbitfild;

    uint            m_position;
}
FTPHead;

enum    islastpack  {NOTLAST_P,LAST_P};
enum    iscommand   {COMMAND_C,FILE_C};


#endif /* FTPPROTOCOL_H_INCLUDED*/
